<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数</title>
</head>

<body>
    <script>
        function add(a, b, c) {
            return a + b + c
        }
        let result = add(1, 2, 3)
        console.log(result);

        //参数默认值,一般都放到最后
        function add1(a, b, c = 10) {
            return a + b + c
        }
        let result1 = add1(1, 2)
        console.log(result1);

        //参数解构
        function connection({ host = '127.0.0.1', username, password, port }) {
            console.log(host);
            console.log(username);
            console.log(password);
            console.log(port);
        }

        connection({
            host: '127.0.0.10',
            username: 'root',
            password: 'root',
            port: 3306
        })

        //参数变量
        function getArgs(...args) {
            console.log(arguments);
            console.log(args);
        }

        getArgs('aa', 'bb', 'cc')

    </script>
</body>

</html>